﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SIGEB.Prototipo.Control;
using Microsoft.Win32;
using System.IO;
using System.Diagnostics;

namespace SIGEB.Prototipo.Vista
{
    public partial class AcercaDe : frm_Base
    {
        public AcercaDe()
        {
            InitializeComponent();
            asignarUI(this.Controls);
        }

        private void StartSysInfo(string strSysInfo)
        {
            try
            {
                Process.Start(strSysInfo);
            }
            catch (Win32Exception ex)
            {
                MessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        public bool GetMsinfo32Path(ref string strPath)
        {
            strPath = String.Empty;
            object objTmp = null;
            RegistryKey regKey = Registry.LocalMachine;
            if (regKey != null)
            {
                regKey = regKey.OpenSubKey("Software\\Microsoft\\Shared Tools\\MSInfo");
                if (regKey != null)
                    objTmp = regKey.GetValue("Path");
                if (objTmp == null)
                {
                    regKey = regKey.OpenSubKey("Software\\Microsoft\\Shared Tools Location");
                    if (regKey != null)
                    {
                        objTmp = regKey.GetValue("MSInfo");
                        if (objTmp != null)
                            strPath = Path.Combine(objTmp.ToString(), "MSInfo32.exe");
                    }
                }
                else
                    strPath = objTmp.ToString();
                try
                {
                    FileInfo fi = new FileInfo(strPath);
                    return fi.Exists;
                }
                catch (ArgumentException)
                {
                    strPath = string.Empty;
                }
            }
            return false;
        }
        
        private void button2_Click(object sender, EventArgs e)
        {
            string strSysInfo = string.Empty;
            if (GetMsinfo32Path(ref strSysInfo))
            {
                StartSysInfo(strSysInfo);
            }	
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
